package com.cloudoer.blog.service.impl;

import com.cloudoer.blog.base.BaseService;
import com.cloudoer.blog.model.Member;
import com.cloudoer.blog.service.MemberService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service(value = "memberService")
public class MemberServiceImpl extends BaseService implements MemberService {
    @Override
    public Member getById(String id) {
        return memberDao.selectById(id);
    }

    @Override
    public String add(Member member) {
        member.setId(UUID.randomUUID().toString().replace("-", ""));
        memberDao.insertSelective(member);
        return member.getId();
    }

    @Override
    public int update(Member member) {
        return memberDao.updateByPrimaryKeySelective(member);
    }

    @Override
    public int delete(String id) {
        return memberDao.deleteByPrimaryKey(id);
    }

    @Override
    public List<Member> getByPage(int pstart, int psize) {
        return memberDao.selectByPage(pstart, psize);
    }

    @Override
    public int getCount() {
        return memberDao.selectCount();
    }
}
